﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GetServiceReference;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // create menu left
            flyout.InnerHtml += (new GenerateMenu()).createMenu("SearchPage.aspx", "category");
            // get and binding data
            GetItemServiceClient gic = new GetItemServiceClient();
            Item[] listNew = gic.getAll("All", default(Guid), default(Guid), 0, float.MaxValue, 12);
            newListItem.DataSource = listNew;
            newListItem.DataBind();
        }
    }
    protected void SortChange(object sender, EventArgs e)
    {
        // get data
        GetItemServiceClient gic = new GetItemServiceClient();
        List<Item> list = gic.getAll("All", default(Guid), default(Guid), 0, float.MaxValue, 12).ToList();
        // sort data
        if (sortBy.SelectedValue.Equals("New"))
        {
            list = list.OrderByDescending(q=>q.Bid_StartDate).ToList();
        }
        if (sortBy.SelectedValue.Equals("Decrement price"))
        {
            list = list.OrderByDescending(q => q.CurrentPrice).ToList();
        }
        if (sortBy.SelectedValue.Equals("Increment price"))
        {
            list = list.OrderBy(q => q.CurrentPrice).ToList();
        }
        newListItem.DataSource = list;
        newListItem.DataBind();
    }
}